define(['egis'],
    function (egis) {
        Window.deserializer = Window.deserializer || new egis.core.Deserializer();
        Window.container = Window.container || {};
        dsBridge.register('create_SelectElementTool', function (sourceId, commandId) {
            var selectElementTool = new egis.interact.SelectElementTool({id: commandId});
            selectElementTool.onSelectElement = function (layer, element) {
                //dsBridge.call("onSelectElement", [layer.id, JSON.stringify(element)]);
                Window.container[element.id] = element;
                dsBridge.call("egis.SelectElementTool_onSelectElement", [sourceId,layer.id, JSON.stringify(element)]);
            }

            selectElementTool.onUnSelectElement = function () {
                //dsBridge.call("onUnSelectElement", [undefined]);
                dsBridge.call("egis.SelectElementTool_onUnSelectElement", [sourceId,undefined]);
            }
            Window.container[sourceId] = selectElementTool;
        });

        dsBridge.register('SelectElementTool_onClick', function (sourceId, param) {
            try {
                var selectElementTool = Window.container[sourceId];
                if (!!selectElementTool) {
                    selectElementTool.onClick(param);
                }
            }
            catch (e) {
                alert(e)
            }
        });
    })